package com.tml;

import com.tml.dao.SmbmsUserDao;
import com.tml.entry.SmbmsUser;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.io.IOException;


public class MainTest {
    public static void main(String[] args) {
        String config = "mybatis-config.xml";
        try{
            InputStream inputStream = Resources.getResourceAsStream(config);
            SqlSessionFactoryBuilder sqlSessionFactoryBuilder=new SqlSessionFactoryBuilder();
            SqlSessionFactory sqlSessionFactory= sqlSessionFactoryBuilder.build(inputStream);
            SqlSession sqlSession =sqlSessionFactory.openSession();
            SmbmsUserDao smbmsUserDao=sqlSession.getMapper(SmbmsUserDao.class);
            SmbmsUser smbmsUser=smbmsUserDao.getSmbmsUserByUserCode("admin");
            System.out.println(smbmsUser);
        }catch(IOException e){
            e.printStackTrace();
        }
    }
}
